"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var MenuService = /** @class */ (function () {
    function MenuService(router, httpService) {
        this.router = router;
        this.httpService = httpService;
        this.eventbus = new core_1.EventEmitter();
    }
    // 获取Menu
    MenuService.prototype.getMenu = function () {
        var url = 'http://118.178.227.204:8091' + "/v1/common/getMenu"; // 临时端口，正式替换成adSystemApiUrl
        return this.httpService.httpGetAuth(url).map(function (data) {
            return data;
        });
    };
    MenuService.prototype.updateMenu = function (routes) {
        this.menus = routes;
        // console.log(this.menus);
    };
    MenuService.prototype.getCurrentMenuItemTitle = function (path) {
        var arrUrl1 = '';
        arrUrl1 = path.substring(0, path.indexOf('?'));
        var arrUrl;
        if (arrUrl1 !== '') {
            arrUrl = arrUrl1.split('/');
        }
        else {
            arrUrl = path.split('/');
        }
        // const arrUrl = arrUrl1.split('/');
        var _path = '';
        if (!this.menus) {
            return;
        }
        // console.log(arrUrl);
        this.menus.forEach(function (items) {
            if (!items) {
                return;
            }
            items.forEach(function (item) {
                if (arrUrl[1] === item.path) {
                    _path = item.title;
                    item.children.forEach(function (ite) {
                        if (arrUrl[2] === ite.path) {
                            _path = ite.title;
                            if (ite.children) {
                                ite.children.forEach(function (it) {
                                    if (arrUrl[3] === it.path) {
                                        _path = it.title;
                                    }
                                });
                            }
                        }
                    });
                }
            });
        });
        // console.log(_path);
        return _path;
    };
    MenuService = __decorate([
        core_1.Injectable()
    ], MenuService);
    return MenuService;
}());
exports.MenuService = MenuService;
